---
layout: api
title: "v2.0.0 JavaScript Library: L.DomEvent"
categories: api
version: v2.0.0
permalink: /api/v2.0.0/l-domevent/
---
<h2 id="domevent">DomEvent</h2>

<p>Utility functions to work with the DOM events, used by Leaflet internally.</p>

<h3>Methods</h3>

<table data-id='domevent'>
	<tr>
<th>Method</th>
<th>Returns</th>
<th>Description</th>
	</tr>
	<tr>
<td><code><b>addListener</b>(
<nobr>&lt;HTMLElement&gt; <i>el</i></nobr>,
<nobr>&lt;String&gt; <i>type</i></nobr>,
<nobr>&lt;Function&gt; <i>fn</i></nobr>,
<nobr>&lt;Object&gt; <i>context?</i> )</nobr>
</code></td>

<td><code><span class="keyword">this</span></code></td>
<td>Adds a listener <code>fn</code> to the element's DOM event of the specified type. <code><span class="keyword">this</span></code> keyword inside the listener will point to <code>context</code>, or to the element if not specified.</td>
	</tr>
	<tr>
<td><code><b>removeListener</b>(
<nobr>&lt;HTMLElement&gt; <i>el</i></nobr>,
<nobr>&lt;String&gt; <i>type</i></nobr>,
<nobr>&lt;Function&gt; <i>fn</i> )</nobr>
</code></td>

<td><code><span class="keyword">this</span></code></td>
<td>Removes an event listener from the element.</td>
	</tr>
	<tr>
<td><code><b>stopPropagation</b>(
<nobr>&lt;DOMEvent&gt; <i>e</i> )</nobr>
</code></td>

<td><code><span class="keyword">this</span></code></td>
<td>Stop the given event from propagation to parent elements. Used inside the listener functions:
<pre><code>L.DomEvent.addListener(div, 'click', function (e) {
	L.DomEvent.stopPropagation(e);
});</code></pre>
</td>
	</tr>
	<tr>
<td><code><b>preventDefault</b>(
<nobr>&lt;DOMEvent&gt; <i>e</i> )</nobr>
</code></td>

<td><code><span class="keyword">this</span></code></td>
<td>Prevents the default action of the event from happening (such as following a link in the <code>href</code> of the <code>a</code> element, or doing a <code>POST</code> request with page reload when <code>form</code> is submitted). Use it inside listener functions.</pre>
</td>
	</tr>
	<tr>
<td><code><b>stop</b>(
<nobr>&lt;DOMEvent&gt; <i>e</i> )</nobr>
</code></td>

<td><code><span class="keyword">this</span></code></td>
<td>Does <code>stopPropagation</code> and <code>preventDefault</code> at the same time.</td>
	</tr>
	<tr>
<td><code><b>disableClickPropagation</b>(
<nobr>&lt;HTMLElement&gt; <i>el</i> )</nobr>
</code></td>

<td><code><span class="keyword">this</span></code></td>
<td>Adds <code>stopPropagation</code> to the element's <code><span class="string">'click'</span></code>, <code><span class="string">'doubleclick'</span></code>, <code><span class="string">'mousedown'</span></code> and <code><span class="string">'touchstart'</span></code> events.</td>
	</tr>
	<tr>
<td><code><b>getMousePosition</b>(
<nobr>&lt;DOMEvent&gt; <i>e</i></nobr>,
<nobr>&lt;HTMLElement&gt; <i>container?</i> )</nobr>
</code></td>

<td><code><a href="/mapbox.js/api/v2.0.0/l-point">Point</a></code></td>
<td>Gets normalized mouse position from a DOM event relative to the container or to the whole page if not specified.</td>
	</tr>
	<tr>
<td><code><b>getWheelDelta</b>(
<nobr>&lt;DOMEvent&gt; <i>e</i> )</nobr>
</code></td>

<td><code>Number</code></td>
<td>Gets normalized wheel delta from a <code>mousewheel</code> DOM event.</td>
	</tr>
</table>



